#ifndef SCUSERDB_H
#define SCUSERDB_H

#include "SocketLib.h"
#include <string>
#include <list>

using std::string;
using SocketLib::Connection;
using SocketLib::Telnet;

class User{
public:
	string name;
	Connection<Telnet>* connection;

public:
	User(){ connection = 0; }
	User(Connection<Telnet>* c, string& n)
	:connection(c), name(n){}


};

class UserDatabase{
public:
	typedef std::list<User> users;
	typedef std::list<User>::iterator iterator;
	typedef Connection<Telnet> conn;

	static iterator Begin(){ return m_users.begin(); }
	static iterator End(){ return m_users.end(); }
	static iterator Find(const conn* p_conn);
	//const class can call const functions only
	static bool AddUser(conn* p_conn, string& p_name);
	static void DeleteUser(const conn* p_conn);
	static bool HasUser(const string& p_name);
	static bool IsValidName(const string& p_name);

protected:
	static users m_users;

};

#endif